const express = require('express');
const bodyParser = require('body-parser')
const app = express();
app.use(express.static(__dirname + '/data'));
const port = 3002;
const Router  = require("./router/router")
const filesRouter = require("./router/file")
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.all('*',function(req,res,next){
  res.header('Access-Control-Allow-Origin', '*');//的允许所有域名的端口请求（跨域解决）
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  res.header('Access-Control-Allow-Methods', '*');
  res.header('Content-Type', 'application/json;charset=utf-8');
  next();
})
app.use('/',Router)
app.use('/',filesRouter)
app.get('/',(req,res)=>{
  res.send('hello homePageServer')
})
app.listen(port,()=>{
  console.log('homepage启用成功')
})